package com.xyzwps.orm.ormlite;

import com.j256.ormlite.db.MysqlDatabaseType;
import com.j256.ormlite.jdbc.DataSourceConnectionSource;
import com.zaxxer.hikari.HikariDataSource;
import lombok.Getter;
import lombok.SneakyThrows;

import java.sql.SQLException;

public class App {

    @Getter
    private final DataSourceConnectionSource dscs;

    public App() {
        var ds = new HikariDataSource();
        ds.setJdbcUrl("jdbc:mysql://localhost:3306/orm");
        ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
        ds.setUsername("scott");
        ds.setPassword("tiger");
        var mysql = new MysqlDatabaseType();
        try {
            this.dscs = new DataSourceConnectionSource(ds, mysql);
        } catch (SQLException ex) {
            throw new IllegalStateException(ex);
        }
    }
}
